home *** CD-ROM | disk | FTP | other *** search
- /* file: busybox.c */
-
- /* 5:59 6/13/90 Started - Larry, Hoover, &Dan
-
- */
- /* let's keep the functions in alphabetical order,
- except for the individual drawing "objects" - those'll probably
- be in their own source files anywayz */
-
- #include "busybox.h"
-
-
- #define NumMasters 5
- #define BusyWindow 401
-
- /* menu stuff*/
- SetUpMenus(void);
- int HandleMenu(long mResult);
- void DoAbout(void);
- int MainEvent(void);
- DoKeyDownStuff(char theChar,long modify);
-
- /* more window stuff */
- MenuHandle myMenus[3];
-
-
-
- ObjInfo stuff[20];
-
- WindowPtr busyWindow;
- int16 numObjects;
- RgnHandle tempRgnHandle; /* for use with GetClip */
-
- void BeBusy(void) {
- static int16 nextBusy;
-
- switch (nextBusy) {
- case 0:
- /* do, say, radar */
- SetUp(1);
- DrawRadarObj(1);
- nextBusy++;
- break;
- case 1:
- /* do, say, heartbeet */
- SetUp(2);
- DrawSillyBallz(2);
- nextBusy++;
- break;
- /* ... */
- case 2:
- /* do, say, heartbeet */
- SetUp(3);
- DrawRandomDotObj(3);
- nextBusy++;
- break;
- /* ... */
- case 3:
- SetUp(4);
- DrawFYAHObj(4);
- nextBusy++;
- break;
- /* ... */
- case 4:
- SetUp(5);
- DrawMeterObj(5);
- nextBusy++;
- break;
- /* ... */
- case 5:
- SetUp(6);
- DrawHeartBeatObj(6);
- nextBusy = 0; /* and it all starts over again */
- break;
- }
- TakeDown(1); /* kludgey */
- } /* BeBusy */
-
-
-
- void SetUp(int16 ID) {
-
- SetClip(stuff[ID].clip);
- SetOrigin(stuff[ID].h, stuff[ID].v);
- /* clip stuff */
- } /* SetUp */
-
-
- void TakeDown(int16 ID) {
- SetOrigin(0, 0);
- } /* TakeDown */
-
-
- void StowObjInfo(Rect *tempRect, int16 ID) {
- RgnHandle tempRgn;
-
- stuff[ID].rect = *tempRect;
- stuff[ID].h = -tempRect->left;
- stuff[ID].v = -tempRect->top;
- InsetRect(&stuff[ID].rect,-1,-1);
- tempRgn = NewRgn();
- OffsetRect(tempRect, stuff[ID].h, stuff[ID].v);
- RectRgn(tempRgn, tempRect);
- stuff[ID].clip = tempRgn;
- } /* StowObjInfo */
-
-
-
- void InitBusyBox(void) {
- Rect tempRect;
- RgnHandle tempRgn;
-
- busyWindow = GetNewWindow(BusyWindow, nil, (WindowPtr)-1);
- SetPort(busyWindow);
-
- SetRect(&tempRect, 2, 2, 76, 76);
- StowObjInfo(&tempRect, 1);
- InitRadarObj(&tempRect, 1);
-
- SetRect(&tempRect, 2, 79, 76, 161);
- StowObjInfo(&tempRect, 2);
- InitSillyBallz(&tempRect, 2);
-
- SetRect(&tempRect, 2, 164, 76, 236);
- StowObjInfo(&tempRect, 3);
- InitRandomDotObj(&tempRect, 3);
-
- SetRect(&tempRect, 79, 2, 211, 236);
- StowObjInfo(&tempRect, 4);
- InitFYAHObj(&tempRect, 4);
-
- SetRect(&tempRect, 214, 2, 352, 172);
- StowObjInfo(&tempRect, 5);
- InitMeterObj(&tempRect, 5);
-
- SetRect(&tempRect, 214, 175, 352, 236);
- StowObjInfo(&tempRect, 6);
- InitHeartBeatObj(&tempRect, 6);
-
- numObjects = 6;
-
- stuff[0].clip = NewRgn();
- GetClip(stuff[0].clip); /* get the wide-open clipping region */
- } /* InitBusyBox */
-
-
-
- void DoSomeUpdateStuff(void) {
- int16 i;
-
- /* set the clipping wide open */
- SetClip(stuff[0].clip);
-
- for (i = 1; i <= numObjects; i++) {
- FrameRect(&stuff[i].rect);
- }
- } /* DoSomeUpdateStuff */
-
-
-
- void InitManagers(int16 numMasters) {
- int16 i;
-
- InitGraf(&thePort);
- InitFonts();
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs(nil);
- for (i = 0; i < NumMasters; i++) {
- MoreMasters();
- }
- FlushEvents( everyEvent, 0 );
- InitCursor();
- } /* InitManagers */
-
-
-
- main() {
- EventRecord theEvent;
-
- InitManagers(NumMasters);
- SetUpMenus();
- InitBusyBox(); /* load trig tables, windows, menus, etc... */
- while(MainEvent());
- } /* main */
-
-
- int MainEvent()
- {
- EventRecord myEvent;
- WindowPtr whichWindow;
- Rect r;
-
-
- SystemTask();
- if (GetNextEvent(everyEvent, &myEvent)) {
- switch (myEvent.what) {
- case mouseDown: /* the mouse has been pressed */
- switch (FindWindow( myEvent.where, &whichWindow )) {
- case inDesk: /* in the desktop area */
- break;
- case inMenuBar: /* in the menu bar */
- return(HandleMenu(MenuSelect(myEvent.where)));
- break;
- case inGoAway: /* in a go away box */
- break;
- case inSysWindow: /* handle a DA or other sys window*/
- break;
- case inContent: /* in the content area of a window */
- break;
- case inDrag:
- SetRect(&r, 0, 0, 5000, 5000);
- DragWindow(whichWindow, myEvent.where, &r);
- }
- break;
- case keyDown: /* a key is being pressed */
- case autoKey: /* and still being pressed */
- /* pass the character to DoKeyStuff */
- DoKeyDownStuff(myEvent.message & charCodeMask,myEvent.modifiers);
- /* are we going to have any keystuff ?? */
- break;
- case activateEvt: /* activate a window */
-
- break;
- case updateEvt: /* time to get that new update */
- DoSomeUpdateStuff();
- break;
- default:;
-
- }
- }
- BeBusy();
- HiliteMenu(0);
- return(1);
- }
-
-
-
- void DoAbout()
- {
- Boolean done;
- int theItem;
- DialogPtr AboutPtr;
- int itemType;
- Handle item;
- Rect box;
-
- done = FALSE;
- AboutPtr = GetNewDialog(AboutDlog,0L,(WindowPtr)-1);
-
- while (!done) {
- ModalDialog(0L,&theItem);
- switch (theItem) {
- case OK:
- done = TRUE;
- break;
- case Cancel:
- done = TRUE;
- break;
- }
- }
- DisposDialog(AboutPtr);
- }
-
- SetUpMenus()
- {
- int i;
- myMenus[appleMenu] = GetMenu(AppleID);
-
- if (ResError())
- SysBeep(5);
-
- AddResMenu( myMenus[appleMenu], 'DRVR' ); /* add in the DAs */
- myMenus[fileMenu] = GetMenu(FileID);
- myMenus[editMenu] = GetMenu(EditID);
- for ( (i=appleMenu); (i<=editMenu); i++ ) InsertMenu(myMenus[i], 0) ;
- DrawMenuBar();
- }
-
-
- int HandleMenu(long mResult)
-
- {
- int theItem, theChoice, temp;
- Str255 name;
- WindowPeek wPtr;
-
- theItem = LoWord(mResult);
- switch (HiWord(mResult)) {
- case AppleID: /* handle menu choices */
- switch (theItem) {
- case appleabout:
- DoAbout();
- break;
- default:
- GetItem(myMenus[appleMenu], theItem, &name);
- OpenDeskAcc( &name );
- break;
- }
- break;
- case FileID: /* handle file menu choices */
- switch (theItem) {
- case quitCmd: /* all done, let's go pick up some chicks */
- ExitToShell();
- break;
- }
- break;
- case EditID: /* handle edit menu choices */
- if (SystemEdit(theItem-1)==0) {
- wPtr = (WindowPeek) FrontWindow();
- switch (theItem) {
- case cutCmd:
- break;
- case copyCmd:
- break;
- case pasteCmd:
- break;
- case clearCmd:
- break;
- default:
- break;
- }
- }
- break;
-
- }
- return(1);
- }
-
-
- DoKeyDownStuff(char theChar,long modify)
- {
- if ((modify & cmdKey) != 0) /*check for control key down*/
- HandleMenu(MenuKey(theChar)); /*true, call Menu Mgr.*/
- }
-
-
-